<pre>
<?php

//print_r($_SERVER);

define('DS', DIRECTORY_SEPARATOR);
define('EXT', pathinfo(__FILE__, PATHINFO_EXTENSION));

$_SERVER['REQUEST_URI'] = strtolower(trim($_SERVER['REQUEST_URI']));

define('BASE_URL', 'http://' . strtolower($_SERVER['HTTP_HOST']));;
define('FULL_URL', BASE_URL . $_SERVER['REQUEST_URI']);

$uri = explode('/', $_SERVER['REQUEST_URI']);
unset($uri[0]);
$controller = empty($uri[1]) || ($uri[1] == 'index.php' && empty($uri[2])) ? 'index' : $uri[2];
$method = empty($uri[3]) ? 'index' : $uri[3];
$arguments = empty($uri[4]) ? NULL : reindex(array_slice($uri, 3));




/*if (!strstr($_SERVER['REQUEST_URI'], 'index.php')) {
	header('Location: /index.php'); exit();
}

require_once('config.php');
require_once(DIR_SFC . 'functions/default.php'); // A hack

error_reporting(E_ALL | E_STRICT);

function __autoload($className)
{
        $fileName = DIR_CLASSES . substr(strtolower($className), 4) . EXT;

        if (is_readable($fileName) == false) {
				trigger_error(basename($fileName));
        } else {
				include_once($fileName);
		}
}

// Clean incoming globals
if ( get_magic_quotes_gpc() ) {
	function stripslashes_deep($value)
	{
		$value = is_array($value) ?
					array_map('stripslashes_deep', $value) :
					stripslashes($value);	
		return $value;
	}
	$_POST = array_map( 'stripslashes_deep', $_POST );
	$_GET = array_map( 'stripslashes_deep', $_GET );
	$_COOKIE = array_map( 'stripslashes_deep', $_COOKIE );
	$_REQUEST = array_map( 'stripslashes_deep', $_REQUEST );
}

// Segment the URI
$uri = reindex(array_slice(explode('/', $_SERVER['REQUEST_URI']), 1));

// Extract the $C, $M, and any $arguments
$controller = empty($uri[1]) || ($uri[1] == 'index.php' && empty($uri[2])) ? 'index' : $uri[2];
$method = empty($uri[3]) ? 'index' : $uri[3];
$arguments = empty($uri[4]) ? NULL : reindex(array_slice($uri, 3));

$controller = $controller == 'admin' ? 'login' : $controller;

// Let the user decide the controller name and location convention
$paths = array(
				DIR_CONTROLLERS . $controller . EXT,
				DIR_CONTROLLERS . $controller . '_controller' . EXT,
				DIR_CONTROLLERS . $controller . DS . $controller . EXT,
				DIR_CONTROLLERS . $controller . DS . $controller . '_controller' . EXT
			  );
			  
// Which path from $paths takes us to $controller?
$pathNum = afne(array_map('is_readable', $paths));

// None? Invalid $controller requested. Back home we go.
if ($pathNum == FALSE) {
	home();
} else {
	// Load the controller
	require_once($paths[$pathNum]);
	$className = $controller . '_Controller';
	$class = new $className;
	if (method_exists($class, $method)) {
		// Let the controller take over from here
		call_user_func_array(array($class, $method), $arguments);
		exit();
	} else {
		home();
	}
}

*/

?>
